package cn.com.ghy.android.bean;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.xmlpull.v1.XmlPullParser;

import android.util.Xml;

/**
 * @软件著作权:金红叶纸业集团有限公司
 * @系统名称:SFA系统
 * @Description:品类销售解析类
 * @author wuz  @date 2011-6-23 10:04:31
 * @版本历史:v1.0
 * @Copyright:Copyright (c) 2011-2012 
 */

public class OrderSellCategoryBeanParser {

	public static List<OrderSellCategoryBean> parseXML(InputStream in) throws Exception {
		XmlPullParser parser = Xml.newPullParser();
		parser.setInput(in, "UTF-8");
		int type = parser.getEventType();

		List<OrderSellCategoryBean> list = null;
		OrderSellCategoryBean bean = null;

		while (type != XmlPullParser.END_DOCUMENT) {
			switch (type) {
				case XmlPullParser.START_DOCUMENT :
					list = new ArrayList<OrderSellCategoryBean>();
					break;

				case XmlPullParser.START_TAG :
					if ("Table".equals(parser.getName())) {
						bean = new OrderSellCategoryBean();
					} else if (null != bean) {
						if ("RT".equals(parser.getName())) {
							bean.setRT(parser.nextText());
						} else if ("CRT".equals(parser.getName())) {
							bean.setCRT(parser.nextText());
						} else if ("JRT".equals(parser.getName())) {
							bean.setJRT(parser.nextText());
						} else if ("IT".equals(parser.getName())) {
							bean.setIT(parser.nextText());
						} else if ("BF".equals(parser.getName())) {
							bean.setBF(parser.nextText());
						} else if ("IF".equals(parser.getName())) {
							bean.setIF(parser.nextText());
						} else if ("PF".equals(parser.getName())) {
							bean.setPF(parser.nextText());
						} else if ("HKS".equals(parser.getName())) {
							bean.setHKS(parser.nextText());
						} else if ("HKM".equals(parser.getName())) {
							bean.setHKM(parser.nextText());
						} else if ("NK".equals(parser.getName())) {
							bean.setNK(parser.nextText());
						} else if ("FT".equals(parser.getName())) {
							bean.setFT(parser.nextText());
						} else if ("HT".equals(parser.getName())) {
							bean.setHT(parser.nextText());
						} else if ("KT".equals(parser.getName())) {
							bean.setKT(parser.nextText());
						} else if ("WT".equals(parser.getName())) {
							bean.setWT(parser.nextText());
						} else if ("TOTALSENDMONEY".equals(parser.getName())) {
							bean.setTOTALSENDMONEY(parser.nextText());
						}
					}
					break;

				case XmlPullParser.END_TAG :
					if ("Table".equals(parser.getName())) {
						list.add(bean);
						bean = null;
					}
					break;
			}
			type = parser.next();
		}
		in.close();
		return list;
	}
}
